<?php

namespace Common\Model;

use Common\Model\XuecheModel;

class MemberPointModel extends XuecheModel {

    protected $pk = 'id';
    protected $tableName = 'member_point';
    protected $fields = array(
        'id', 'member_id', 'point', 'change_point', 'addtime', 'expiretime','reason'
    );


    /**
     * 清空数据缓存
     *
     */
    public function ClearAllCache() {

    }

    //缓存设置
    protected $_useCacheType = 'file';
    protected $_catheTime = 36000;

    public function Validate($data) {
        return true;
    }

    //获取会员积分数
    public function getMemberPoint($member_id){
        if($member_id > 0){
            if($info = $this->where("`member_id` = '{$member_id}'")->order('id DESC')->field('point')->find()){
                return $info['point'];
            }
            return 0;
        }
    }


}
